#include "Project_main3.h"




extern unsigned char IP_Hao;
uint8_t max_Th3 = 0;
uint8_t max_Tl3 = 0;
extern uint8_t max_num3;

void get_temp3(void)
{
	float temp;
    uint8_t temp_buff[max_Th3][max_Tl3][2];
//    uint8_t temp_buff[30][4][2];
    for (int i = 0; i < max_Th3; i++) {
        for (int j = 0; j < max_Tl3; j++) {
            for (int k = 0; k < 2; k++) {
                temp_buff[i][j][k] = 0xff;
            }
        }
    }

    GXHT3W_Search_Rom();
	if(max_num3 != GXHT3W_SensorNum)
	{
		get_Search3(&max_num3);
	}

    for (int num = 0; num < GXHT3W_SensorNum; num++) {
		GXHT3W_change_Temp(ucGXHT3WId[num]);
    }
	OneWire3_UP_1;
	delay_ms(800);
	OneWire3_UP_0;
	//----------------------------------------------------------
	    for (int num = 0; num < GXHT3W_SensorNum; num++) {

//				readT = 0;
				temp = GXHT3W_Read_Temp(ucGXHT3WId[num], &GXHT3W_Th, &GXHT3W_Tl);
				temp_buff[GXHT3W_Th - 1][GXHT3W_Tl - 1][0] = temp;
				temp_buff[GXHT3W_Th - 1][GXHT3W_Tl - 1][1] = temp * 100 - (int)temp * 100;
				OLED_ShowNum(2, 1, temp, 3);
				OLED_ShowChar(2, 4, '.');
				OLED_ShowNum(2, 5, temp * 100 - (int)temp * 100, 2);
				OLED_ShowNum(3, 1, GXHT3W_Th, 2);
				OLED_ShowNum(3, 7, GXHT3W_Tl, 2);
				OLED_ShowNum(4, 1, max_Th3, 5);
				OLED_ShowNum(4, 7, max_Tl3, 5);
//				delay_ms(2);
		
    }
    for (int i = 0; i < max_Th3; i++) {
        for (int j = 0; j < max_Tl3; j++) {
            for (int k = 0; k < 2; k++) {
                UART1Send(temp_buff[i][j][k]);
            }
        }
    }
}

void get_Search3(uint8_t *xh)
{
	float temp;
    GXHT3W_Search_Rom();

    for (int num = 0; num < GXHT3W_SensorNum; num++) {
		GXHT3W_change_Temp(ucGXHT3WId[num]);
    }
	OneWire3_UP_1;
	delay_ms(800);
	OneWire3_UP_0;
	//----------------------------------------------------------
	    for (int num = 0; num < GXHT3W_SensorNum; num++) {
				temp = GXHT3W_Read_Temp(ucGXHT3WId[num], &GXHT3W_Th, &GXHT3W_Tl);
				OLED_ShowNum(2, 1, temp, 3);
				OLED_ShowChar(2, 4, '.');
				OLED_ShowNum(2, 5, temp * 100 - (int)temp * 100, 2);
				OLED_ShowNum(3, 1, GXHT3W_Th, 2);
				OLED_ShowNum(3, 7, GXHT3W_Tl, 2);
				OLED_ShowNum(4, 1, max_Th3, 5);
				OLED_ShowNum(4, 7, max_Tl3, 5);
//						delay_ms(50);
				if (GXHT3W_Th > max_Th3) {
					max_Th3 = GXHT3W_Th;
				}
		
				if (GXHT3W_Tl > max_Tl3) {
					max_Tl3 = GXHT3W_Tl;
				}
		
    }
	//------------------------------------------------------------
	*xh = GXHT3W_SensorNum;
	OLED_ShowNum(1, 1, GXHT3W_SensorNum, 3);
}


